package kltn.audioguidetravel;

import java.util.ArrayList;
import kltn.business.BAInfoTravel;
import kltn.business.InfoTravelAdapter;
import kltn.data.Direction;
import kltn.data.InfoTravel;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;

public class CustomActivity extends Activity{
	
	public ListView lvCustom;
	Direction direc; 
	ArrayList<InfoTravel> infoTravels;
	ArrayList<Integer> IDs=new ArrayList<>();
	Button btnPlay;
	int direcID;
	InfoTravelAdapter adapter;
	@SuppressWarnings("unchecked")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_custom);
		btnPlay=(Button) findViewById(R.id.btnXong);
		btnPlay.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(CustomActivity.this,PlayActivity.class);
				for(int i=0;i<adapter.getCount();i++){
					if(adapter.getItem(i).isShow())
						IDs.add(adapter.getItem(i).getID());
				}
				intent.putExtra("IDs", IDs);
				intent.putExtra("direcID",direcID);
				startActivity(intent);
			}
		});
		Intent intent=getIntent();
		direcID=intent.getIntExtra("direcID",0);
		infoTravels=new BAInfoTravel(this).getInfoByDirect(direcID);
		loadListView();
	}
	private void loadListView(){
		lvCustom= (ListView) findViewById(R.id.lvCustom);
		adapter= new InfoTravelAdapter(this, R.layout.item_choose, infoTravels);
		lvCustom.setAdapter(adapter);
	}
}
